$(function(){
	var messageSuccess = setTimeout(function() {
		$('.message-success').fadeOut('slow');
		clearTimeout(messageSuccess);
	}, 3000);
	
	var navSelector = "ul#menu li";/** define the main navigation selector **/

	/** set up rounded corners for the selected elements **/
	$('.box-container').corners("5px bottom");
	 $('.box h4').corners("5px top");
	 $('ul.tab-menu li a').corners("5px top");
	 
	 /**
	  * options
	  */
	 var options = {
	      strikeThrough : { visible : true },
	      underline     : { visible : true },
	      
	      separator00 : { visible : true },
	      
	      justifyLeft   : { visible : true },
	      justifyCenter : { visible : true },
	      justifyRight  : { visible : true },
	      justifyFull   : { visible : true },
	      
	      separator01 : { visible : true },
	      
	      indent  : { visible : true },
	      outdent : { visible : true },
	      
	      separator02 : { visible : true },
	      
	      subscript   : { visible : true },
	      superscript : { visible : true },
	      
	      separator03 : { visible : true },
	      
	      undo : { visible : true },
	      redo : { visible : true },
	      
	      separator04 : { visible : true },
	      
	      insertOrderedList    : { visible : true },
	      insertUnorderedList  : { visible : true },
	      insertHorizontalRule : { visible : true },

	      separator07 : { visible : true },
	      
	      cut   : { visible : true },
	      copy  : { visible : true },
	      paste : { visible : true },
	      html : { visible : true }
	 };
	 //$('textarea.wysiwyg').wysiwyg({ controls: options });
	 
	 $("div#sys-messages-container a, div#to-do-list ul li a").colorbox(/*{fixedWidth:"50%", transitionSpeed:"100", inline:true, href:"#sample-modal"}*/); /** jquery colorbox modal boxes for system
	 messages and to-do list - see colorbox help docs for help: http://colorpowered.com/colorbox/ **/

	$('#to-do').tabs();		 
	$("#calendar").datepicker();/** jquery ui calendar/date picker - see jquery ui docs for help: http://jqueryui.com/demos/ **/
	
	$('.check-all').bind('change', function() {
		var self = this;
		var checked = false;
		if (self.checked == true) {
			checked = true;			
		}
		$('.check-item').each(function() {
			this.checked = checked;
		});
		$('.check-all').attr('checked', checked);
	});
 
	jQuery(navSelector).find('a').css( {backgroundPosition: "0 0"} );
	
	jQuery(navSelector).hover(function(){/** build animated dropdown navigation **/
		jQuery(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show("fast");
		jQuery(this).find('a').stop().animate({backgroundPosition:"(0 -40px)"},{duration:150});
 	   jQuery(this).find('a.top-level').addClass("blue");
		},function(){
		jQuery(this).find('ul:first').css({visibility: "hidden", display:"none"});
		jQuery(this).find('a').stop().animate({backgroundPosition:"(0 0)"}, {duration:75});
		jQuery(this).find('a.top-level').removeClass("blue");
		});
	});

function generateSlug(str) {
	str = str.replace(/^\s+|\s+$/g, '');
  	var from = "ÁÀẠẢÃĂẮẰẶẲẴÂẤẦẬẨẪáàạảãăắằặẳẵâấầậẩẫóòọỏõÓÒỌỎÕôốồộổỗÔỐỒỘỔỖơớờợởỡƠỚỜỢỞỠéèẹẻẽÉÈẸẺẼêếềệểễÊẾỀỆỂỄúùụủũÚÙỤỦŨưứừựửữƯỨỪỰỬỮíìịỉĩÍÌỊỈĨýỳỵỷỹÝỲỴỶỸĐđÑñÇç·/_,:;";
  	var to   = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaooooooooooooooooooooooooooooooooooeeeeeeeeeeeeeeeeeeeeeeuuuuuuuuuuuuuuuuuuuuuuiiiiiiiiiiyyyyyyyyyyddnncc------";
  	
  	for (var i = 0, l = from.length ; i < l; i++) {
    	str = str.replace(new RegExp(from[i], "g"), to[i]);
  	}
  	str = str.replace(/[^a-zA-Z0-9 -]/g, '').replace(/\s+/g, '-').toLowerCase();
  	return str;
}